import os

Import('env')
with open(env['PROJECT_TOOL_S']) as f:
    exec(f.read())

# SRCS = append_srcs_dir(ADir('src'))
SRCS = Glob('src/*.c*')
INCLUDE = [ADir('include'), ADir('.')]
PRIVATE_INCLUDE = []
REQUIREMENTS = ['pthread', 'utilities', 'ax_msp', 'eventpp', 'StackFlow', 'single_header_libs']
STATIC_LIB = []
DYNAMIC_LIB = []
DEFINITIONS = []
DEFINITIONS_PRIVATE = []
LDFLAGS = []
LINK_SEARCH_PATH = []
STATIC_FILES = []

DEFINITIONS += ['-std=c++17']
LDFLAGS+=['-Wl,-rpath=/opt/m5stack/lib', '-Wl,-rpath=/usr/local/m5stack/lib', '-Wl,-rpath=/usr/local/m5stack/lib/gcc-10.3', '-Wl,-rpath=/opt/lib', '-Wl,-rpath=/opt/usr/lib', '-Wl,-rpath=./']
# INCLUDE += [ADir('../include'), ADir('../include/cppzmq'), ADir('../include/libzmq')]
LINK_SEARCH_PATH += [ADir('../static_lib')]

REQUIREMENTS += ['ax_sys', 'ax_interpreter']

INCLUDE += [ADir('../include/opencv4')]
static_file = []
static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/libopencv_core.a')]
static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/libittnotify.a')]
static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/liblibjpeg-turbo.a')]
static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/liblibopenjp2.a')]
static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/liblibpng.a')]
static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/liblibtiff.a')]
static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/liblibwebp.a')]
static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/libopencv_core.a')]
static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/libopencv_highgui.a')]
static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/libopencv_imgcodecs.a')]
static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/libopencv_imgproc.a')]
static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/libopencv_videoio.a')]
static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/libtegra_hal.a')]
static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/libzlib.a')]
STATIC_LIB += static_file * 4

STATIC_FILES += [AFile('camera.json')]
STATIC_FILES += Glob('mode_*.json')

env['COMPONENTS'].append({'target':'llm_camera',
                          'SRCS':SRCS,
                          'INCLUDE':INCLUDE,
                          'PRIVATE_INCLUDE':PRIVATE_INCLUDE,
                          'REQUIREMENTS':REQUIREMENTS,
                          'STATIC_LIB':STATIC_LIB,
                          'DYNAMIC_LIB':DYNAMIC_LIB,
                          'DEFINITIONS':DEFINITIONS,
                          'DEFINITIONS_PRIVATE':DEFINITIONS_PRIVATE,
                          'LDFLAGS':LDFLAGS,
                          'LINK_SEARCH_PATH':LINK_SEARCH_PATH,
                          'STATIC_FILES':STATIC_FILES,
                          'REGISTER':'project'
                          })
